package com.zoe.app.controller;

import com.zoe.app.User;
import com.zoe.app.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zbg
 * @date 2023/07/05
 * @description
 */
@RestController
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    // http://localhost:8080/id/3
    @GetMapping("/id/{id}")
    public Integer id(@PathVariable Integer id) {
        return userService.getId(id);
    }

    // http://localhost:8080/getName?id=1&name=张三&address=安徽
    @GetMapping("/getName")
    public String getName(User user) {
        return userService.getName(user);
    }

    // http://localhost:8080/user?id=1&name=张三&address=安徽
    @GetMapping("/user")
    public User user(User user) {
        return userService.getUser(user);
    }

}
